(function() {
    'use strict';

    /**
     * @ngdoc function
     * @name webApp.controller:EvaluateCtrl
     * @description
     * # EvaluateCtrl
     * Controller of the webApp
     */
    angular.module('webApp')
        .controller('EvaluateCtrl', EvaluateCtrl);

    EvaluateCtrl.$inject = ['$scope', 'dataService', '$location', '$state', 'helper', 'sessionService'];

    function EvaluateCtrl($scope, dataService, $location, $state, helper, sessionService) {

        //显示
        $scope.listAction = function() {
            $scope.getorderList();
        }

        //获取列表
        $scope.getorderList = function(pageNo) {
            var user = sessionService.get("tokenUser");

            var query = { page_no: pageNo ? pageNo : "1", page_size: $scope.pageSize };
            query.query = { "partner_id": user.CompanyId };

            dataService.reviewGet(query).then(function(list) {
                if (list) {
                    $scope.orderslist = list.review;
                    $scope.ordersTotal = list.total_count;
                }
            });
        }

        //显示
        $scope.infoAction = function() {
            var id = $location.search().review_id;
            if (id) {
                dataService.reviewOne(id).then(function(one) {
                    if (one) {
                        $scope.order = one;
                    } else {
                        helper.myAlert("No data found", null, null, function() {
                            $state.go("evaluate.info");
                        });
                    }
                });
            } else {
                helper.myAlert("No data found", null, null, function() {
                    $state.go("evaluate.info");
                });
            }
        }

    }
})();